#pragma once
//#include <memory>

#include <vector>

#include "OptRun.h"

using namespace std;

namespace OptRun{
		
#ifndef _ENUM_GASCHEMA_
#define _ENUM_GASCHEMA_
	enum GASchema {
      OneGA,
      GAinGA,
	  GA_BFA
   };
#endif

	class OptInf
	{
	public:
		OptInf(void);
		~OptInf(void);
		int initializeGA(GASchema gaS = GASchema::OneGA);
		//int initializeGA(GASchema gaS = GASchema::GA_BFA);

		GA1DArrayGenome<int>* genomePtr;
		GASteadyStateGA* gaPtr;
		
		//double objective;
		//double fitness;

		double sndBeamLength;
		double sndBeamDistance;
		double fit;
		double h_p;
		double v_c;
		double m_R;
		double m_p;
		double m_q;
		double A_a;
		double M_plRd_sec;
		double M_yEd_sec;
		double V_Ed_sec;
		double V_plRd_sec;
		double Deflection_sec;
		double EigenFre_sec;
		double M_plRd_neg_pri;
		double M_yEd_neg_pri;
		double M_plRd_pos_pri;
		double M_yEd_pos_pri;
		double PenaltyWeight;

    double F_Ed_m;
    double F_Ed_e;
		double N_b_y_Rd;
		double N_b_z_Rd;
		double k_yy;
		double k_zy;
		double M_Ed_y_col;
		double M_b_y_Rd;

		

		double t_nom; // sheeting thickness
		double LengthSecBeam_3_5; // LengthSecBeam/3.5
		double V_Ed_pri;
		double V_plRd_pri;

		double column_position;
		int column_number;
		int systemAB;
		int sndbeam_number;
		double len;
		double wid;

		//
    //flip[0] = middle columns' location;
    //flip[1] = no_of_columns;
    //flip[2] = slab type;
    //flip[3] = slab_thickness;
    //flip[4] = second beam profile;
    //flip[5] = steel_grade[GARandomInt(0,2)];
    //flip[6] = primary beam profile;
    //flip[7] = steel_grade[GARandomInt(0,2)];
    //flip[8] = primary direction
    //flip[9] = 0; //temp !!!!!!!!!
    //flip[10]= no of secondary beams;

    //flip[11]= column profile Top;
    //flip[12]= steel_grade[GARandomInt(0,2)];
    //flip[13]= column profile -1;
    //flip[14]= steel_grade[GARandomInt(0,2)];
    //flip[15]= column profile -2;
    //flip[16]= steel_grade[GARandomInt(0,2)];
    //flip[17]= column profile -3;
    //flip[18]= steel_grade[GARandomInt(0,2)];
    //flip[19]= column profile -4;
    //flip[10]= steel_grade[GARandomInt(0,2)];
    //flip[21]= column profile -5;
    //flip[22]= steel_grade[GARandomInt(0,2)];
    //flip[23]= column profile -6;
    //flip[24]= steel_grade[GARandomInt(0,2)];
    //flip[25]= column profile -7;
    //flip[26]= steel_grade[GARandomInt(0,2)];
    //flip[27]= column profile -9;
    //flip[28]= steel_grade[GARandomInt(0,2)];
    //flip[29]= column profile -10;
    //flip[30]= steel_grade[GARandomInt(0,2)];
    static const int MAX_NO_OF_GENE = 51; //number of gene 13 for shema 1 oneGA
    static int NO_OF_GENE; //number of gene 13 for shema 1 oneGA
    //
    
		//static const int NO_OF_GENE = 4; //number of gene 4 for schema 3 and 2
		//static const int NO_OF_ProGENE = 8; //number of gene 8 for schema 2 inner GA
		static const double  E_steel; // young's modulus for steel 21000kN/cm2
		static const double  E_concrete; //young's modulus for concrete 3000kN/cm2
		static const double  gamma_M0s; // partial factor of steel
		static const double  gamma_M0c;//partial factor of concrete
		static const double  gamma_S; // partial factor of reinforcement
		static const double  gamma_M1s;//partial factor of steel
		static const double  f_ck; //concrete 30/37 :3kN/cm2
		static const double  f_sk; // reinforcement 50kN/cm2
		static const double  A_s; // reinforcement 3.93cm2/m
		static const double  h_p_holorib; // hp = 51mm SHR51
		static const double  h_p_cofrasta; // hp=60mm Cofraplus60
		static const double  Cmy;  // equivalent factor for moment Cm in columns design
		static const double  CmLT;  // equivalent factor for moment Cm in columns design


		//   
		static double  AddDEADLOAD; //additional dead load 0.0002kN/cm2
		static double  LIVELOAD ; //live load 0.0003 kN/cm2
    static double  PenaltyW;
    static double  PenaltyW_EMPTY;
		static double H_COL;  // column height  //cm
		static int N_of_Floor; // number of floors
		static double coef1; // coeffieciont for fitfunction
		static double coef2;// coeffieciont for fitfunction

		static double ai[5] ;  //energy
		//double ai[5] = {237, 0.874,1.41, 0.80,0}; //GWP
		static int slab_thickness[4] ; // the thickness of slabs could be 120/140/160/180mm
		static int no_of_columns[3]  ;
		static int steel_grade[3] ; // Steel grade could be S235, S355,S460


		static int height1; //there are 65 crosssection intotal
		static int width1; //each cross section has 12 parameters
		static int height2; //table scope of the holorib slab
		static int width2;
		static int height3; // table scope for the moment calculation for the primary beam
		static int width3;
		static int height4; // table for the slab summary
		static int width4;
		static int height5; // table for the moment calculation for system B with 5 spans
		static int width5;

		static vector<vector<double>> CrossSection;
		static vector<string> CrossSectionName;
		//static vector<std::string> CrossSectionName;
		static vector<vector<double>> Holorib;
		static vector<vector<double>> Cofrasta;
		static vector<vector<double>> FullLoad;
		static vector<vector<double>> LeftLoad;
		static vector<vector<double>> RightLoad;
		static vector<vector<double>> SlabProfile;
		static vector<vector<double>> Five_Span_Load;


		//Optimization Parameters
		static int PopulationSize;
		static int GenerationSize;
		static double MutationProbability;
		static double CrossoverProbability;

		//Design Parameters;
		
		static double  LENGTH; // the length of the floor 50m
		static double  WIDTH; // the width of the floor 15m
		static double  H_MAX; // maximum construction height 600mm
		static double  X_COL; // the start range of the column position 4.3m.x_col must >= 4.3m
		static double  Y_COL; // the end range of the column position 5m. y_col must <= 7.5m
		static double  Dist_COL; //the distance between the columns 0.3m

    
    static double deadLoad;
    static double addDeadLoad;
    static double liveLoad;
    static double load_e;
    static double load_m;
    static double min_fit;
    static double PenaltyTotal;
    static double MyEdsec_o_MplRdsec;
    static double VEdsec_o_VplRdsec;
    static double Deflectionsec_o_LengthSecBeam3o5;
    static double VEdpri_o_VplRdpri;
    static double MyEdpospri_o_MplRdpospri;

    static double FEdm_o_NbyRd_m[MAX_NO_OF_GENE*2];
    static double FEde_o_NbyRd_add_kyy_t_MEdy_o_MbyRd_e[MAX_NO_OF_GENE*2];
    static double FEde_o_NbzRd_add_kzy_t_MEdy_o_MbyRd_e[MAX_NO_OF_GENE*2];
	};

}